package com.prodavalnik.model;

public class User {
	private int id;
	private String username;
	private String password;
	private String email;
	private String conn;
	
	public User(int id, String username, String password, String email,
			String conn) {
		super();
		this.id = id;
		this.username = username;
		this.password = password;
		this.email = email;
		this.conn = conn;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getConn() {
		return conn;
	}
	public void setConn(String conn) {
		this.conn = conn;
	}
	
	
	/**
	 * 
	 * @param password
	 * @return true if password is correct (contains at least 8 characters, at least 1 digit(s), 
	 * at least 1 lower case letter(s), at least 1 upper case letter(s))
	 * @return false if password is not correct
	 */
	public static boolean checkPassword(String password){
		
		boolean hasUppercase = false;
        boolean hasLowercase = false;
        boolean isDigit = false;
        
		if(password.length() < 8)
			return false;
		for(int index=0;index<password.length();index++){
			if(Character.isDigit(password.charAt(index))){
				isDigit = true;
			}
			if(Character.isUpperCase(password.charAt(index))){
				hasUppercase = true;
			}
			if(Character.isLowerCase(password.charAt(index))){
				hasLowercase = true;
			}
		}
		if(hasLowercase && hasUppercase && isDigit){
			return true;
		}
		else return false;	
	}
}
